package com.wpam.scrabble.mobile.communication.bt;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;

public class DeviceNetworkInfo {
	
	private BluetoothSocket sock_;
	private InputStream inputStream_;
	private OutputStream outputStream_;
	
	public DeviceNetworkInfo(BluetoothSocket socket, InputStream inStream, OutputStream outStream) {
		
		this.sock_ = socket;
		this.inputStream_ = inStream;
		this.outputStream_ = outStream;
	}

	public BluetoothSocket getSock() {
		return sock_;
	}

	public InputStream getInputStream() {
		return inputStream_;
	}

	public OutputStream getOutputStream() {
		return outputStream_;
	}
	
	public void setSock_(BluetoothSocket sock) {
		
		this.sock_ = sock;
		try {
			this.inputStream_ = sock.getInputStream();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			this.inputStream_ = null;
		}
		try {
			this.outputStream_ = sock.getOutputStream();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			this.outputStream_ = null;
		}
	}

	public void setInputStream_(InputStream inputStream) {
		this.inputStream_ = inputStream;
	}

	public void setOutputStream_(OutputStream outputStream) {
		this.outputStream_ = outputStream;
	}

	@Override
	public boolean equals(Object o) {
		
		if (o instanceof BluetoothDevice) {
			return ((BluetoothDevice) o).equals(sock_.getRemoteDevice());
		} else if (o instanceof DeviceNetworkInfo) {
			return ((DeviceNetworkInfo) o).sock_.equals(sock_);
		} else return false;
	}
}
